# Makefile boot sector
CC	:= gcc
INCLUDE	:= -I. -I../include -I../include/rymos
CFLAGS	:= $(INCLUDE)
# next define is for some header files that are to be used by both the
# kernel and user programs
CFLAGS 	+= -DRYMOS_KERNEL
#CFLAGS	+= -fomit-frame-pointer
# CFLAGS	+= -O2
# -O2 doesn't work yet, some missing volatiles I guess

COBJS   := kernel.o video.o io.o pic.o vga.o mm.o line.o windows.o \
           box.o char.o label.o paging.o idt.o 

ASMOBJS	:= bootf.o
OBJS	:= $(COBJS) $(ASMOBJS)
CFILES  := $(COBJS:%.o=%.c)
ASMFILES:= $(ASMOBJS:%.o=%.asm)
ASM	:= nasm
JLD	:= jloc

bootf.bin :$(ASMOBJS)
	@echo
	@echo Creating $@
	@$(JLD) bootf.lnk $@
	@cp -f $@ ../../bin/boot/$@
	@echo
	@echo RYMOS boot sector $@ compiled. 
	@echo insert a floppy on the floppy drive and 
	@echo Type 'make disk' to make a floppy bootable 

disk: bootf.bin
	PARTCOPY bootf.bin 0 3 -f0 0
	PARTCOPY bootf.bin 3E 1C2 -f0 3E
	
%.o : %.asm
	@echo Compiling $<
	@$(ASM) -i ../include/rymos/ -f obj -l bootf.lst $< -o $@

%.o : %.c
	@echo Compiling $<
	@$(CC) $(CFLAGS) -c $< -o $@



% : %.c
	@echo Compiling $<
	@$(CC) -O2 -o $@ $<



# clean up
.PHONY : clean
clean:
	del *.o
	del *.bin
	del *.lst
	@echo Clean maked.



